package com.example.shutdown_v1.repository;

import com.example.shutdown_v1.entity.AlarmRecord;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface AlarmRecordRepository extends JpaRepository<AlarmRecord, Long> {
    
    /**
     * 查询指定店铺在指定时间范围内的告警记录
     */
    List<AlarmRecord> findByShopIdAndAlarmTimeBetween(
            Long shopId, LocalDateTime startTime, LocalDateTime endTime);
    
    /**
     * 查询未确认的告警记录
     */
    List<AlarmRecord> findByConfirmedOrderByAlarmTimeDesc(Boolean confirmed);
    
    /**
     * 查询指定店铺未确认的告警
     */
    List<AlarmRecord> findByShopIdAndConfirmedOrderByAlarmTimeDesc(Long shopId, Boolean confirmed);
    
    /**
     * 查询指定告警类型的记录
     */
    List<AlarmRecord> findByAlarmTypeAndAlarmTimeBetween(
            String alarmType, LocalDateTime startTime, LocalDateTime endTime);
}

